/**
 * 添加收货地址
 * @returns
 */
function insertHistoryAddress(){
	showDefault("loading","保存中");
	var mobile=$("#mobile").val();
	 var province=$("#province").find("option:checked").html();
	 var area=$("#area").find("option:checked").html();
	 var town=$("#town").find("option:checked").html();
	 var address=$("#baiduaddress").val();
	 /*var province1=(!province ||province=="undefined"? "" : ""+province+"");
	 var city1=(!city ||city=="undefined"? "" : ""+city+"");
	 var area1=(!area ||area=="undefined"? "" : ""+area+"");
	 var town1=(!town ||town=="undefined"? "" : ""+town+"");*/
	if(!mobile.match(/^1[34578]\d{9}$/)||mobile==""){
		toast.hide();
		if(mobile==""){
			showDefault("fail","请添加联系方式");
		}else{
			showDefault("fail","请添加有效的联系方式");
		}
		
	}else{
		var json={"iphone":""+getCookie("useriphone")+"","address":""+province+area+town+address+"","mobile":""+mobile+"","townandstreets":""+town+"","province":""+province+"","city":""+province+"","area":""+area+"","fulladdress":""+address+""};
		$.ajax({
			type: "post",
			datatype: 'json',
			contentType: 'application/json;charset=UTF-8',
			url: ''+httpipstr+'alfa-mobile-ws/rest/historyaddress/insertHistoryAddress?mobiletoken='+getCookie("mobiletokenuser")+'',
			data: JSON.stringify(json),
			success: function(data) {
				toast.hide();
				if(data.message=="4"){
					showDefault("fail","地址添加已达上限");
				}else{
					if($("#defaultaddress").prop("checked")){
					
						var jsonstr = "filterscount=0&groupscount=0&pagenum=0&pagesize=10&recordstartindex=0&recordendindex=10&iphone="+getCookie("useriphone")+"&addressLike=";
						$.ajax({
							cache: false,
							type: "post",
							datatype: 'json',
							contentType: 'application/json;charset=UTF-8',
							data: jsonstr,
							url: ''+httpipstr+'alfa-mobile-ws/rest/historyaddress/findlist?mobiletoken='+getCookie("mobiletokenuser")+'',
							success: function(data) {
								setcookie("recycleaddress", data.rows[0].address, 30, "/");
								setcookie("recycleaddressid", data.rows[0].id, 30, "/");
								setcookie("recycleaddressiphone", data.rows[0].mobile, 30, "/");
								location.href="user_functionAddressList.jsp"
							}
						})
					}else{
						location.href="user_functionAddressList.jsp"
					}
					
				}
			}
		})
	}
}